import java.net.*;
import java.io.*;

public class UDPClient{
    public static void main(String[] args){
        DatagramSocket aSocket=null;
        long sum=0;
        String mm;
        try{
            for(int i=0;i<30;i++){
                aSocket=new DatagramSocket();
                mm = i +"";
                byte[] m = mm.getBytes();
                InetAddress aHost = InetAddress.getByName("127.0.0.1");
                int serverPort = 6789;
                DatagramPacket request = new DatagramPacket(m,mm.length(),aHost,serverPort);

                aSocket.send(request);
                byte[] buffer = new byte[1000];
                DatagramPacket reply = new DatagramPacket(buffer,buffer.length);
                aSocket.receive(reply);

                System.out.println("data : " + new String(reply.getData()));

            }
        }catch(Exception e){
            System.out.println("error");
        }
    }
}
